import time
from selenium import webdriver
from selenium.webdriver.common.by import By
# TODO 导入键盘类
from selenium.webdriver.common.keys import Keys

# 打开浏览器
driver = webdriver.Chrome()
# 请求百度
driver.get('https://www.baidu.com')
# 输入关键字
time.sleep(2)
kw = driver.find_element(By.ID,'kw')
kw.send_keys('天气预报')
# TODO Ctrl a
time.sleep(2)
kw.send_keys(Keys.CONTROL,'a')
# TODO Ctrl c
time.sleep(2)
kw.send_keys(Keys.CONTROL,'c')

# 请求so
driver.get('https://www.so.com')
# 找到360搜索框
ipt = driver.find_element(By.ID,'input')
# TODO Ctrl v
time.sleep(2)
ipt.send_keys(Keys.CONTROL,'v')
# 点击搜索按钮
time.sleep(2)
driver.find_element(By.ID,'search-button').click()

# 退出浏览器
time.sleep(2)
driver.quit()